defmodule ProgContest.Fixtures.Quiz do
  defmacro __using__(_) do
    quote location: :keep do
      alias ProgContest.Quizzes

      @valid_quiz_attrs %{author: "some author", question: "some question", title: "some title"}
      @update_quiz_attrs %{author: "some updated author", question: "some updated question", title: "some updated title"}
      @invalid_quiz_attrs %{author: nil, question: nil, title: nil, contest_id: nil}

      def quiz_fixture(contest, attrs \\ %{}) do
        {:ok, quiz} =
          attrs
          |> Map.put(:contest_id, contest.id)
          |> Enum.into(@valid_quiz_attrs)
          |> Quizzes.create_quiz()
        quiz
      end
    end
  end
end
